package com.office;

import com.office.config.DynamicDataSourceRegister;
import com.office.config.aop.DynamicDataSourceAnnotationAdvisor;
import com.office.config.aop.DynamicDataSourceAnnotationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.transaction.annotation.EnableTransactionManagement;


@Import(DynamicDataSourceRegister.class)
@SpringBootApplication
@MapperScan("com.office.mapper")
@EnableTransactionManagement
public class OfficeApplication {
    public static void main(String[] args) {
        SpringApplication.run(OfficeApplication.class, args);
    }

    @Bean
    public DynamicDataSourceAnnotationAdvisor dynamicDatasourceAnnotationAdvisor() {
        return new DynamicDataSourceAnnotationAdvisor(new DynamicDataSourceAnnotationInterceptor());
    }

}
